package com.cmc.cloud.cmclink.doc.controller.admin.so;

import javax.annotation.Resource;
import javax.validation.Valid;

import com.cmc.cloud.cmclink.doc.api.document.emums.ExImTypeEnum;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.cmc.cloud.cmclink.doc.api.document.emums.ConfirmNoticeEnum;
import com.cmc.cloud.cmclink.doc.service.si.ConfirmNoticeService;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticevo.ConfirmNoticeDetailRespVO;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticevo.ConfirmNoticePageReqVO;
import com.cmc.cloud.cmclink.doc.vo.confirmnoticevo.ConfirmNoticeRespVO;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 查看费用表变更前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - 查看费用表变更")
@RestController
@Validated
@RequestMapping("/doc/v1/show-export-change")
public class ShowExportFreightChangeController {

    @Resource
    private ConfirmNoticeService confirmNoticeService;

    @Operation(summary = "查看费用表变更详情")
    @GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<ConfirmNoticeDetailRespVO> getConfirmNotice(@PathVariable("id") Long id) {
        ConfirmNoticeDetailRespVO resp = confirmNoticeService.getConfirmNotice(id);
        return CommonResult.success(resp);
    }

    @Operation(summary = "查看费用表变更分页")
    @PostMapping("/page")
    @UseResponsePropertyAdvice
    @PreAuthorize("@ss.hasPermission('doc:exportFreightChangePol:search')")
    public CommonResult<PageResult<ConfirmNoticeRespVO>>
        getConfirmNoticePage(@Valid @RequestBody ConfirmNoticePageReqVO pageVO) {
        pageVO.setNotice(ConfirmNoticeEnum.FCN.getValue());
        PageResult<ConfirmNoticeRespVO> pageResult =
            confirmNoticeService.getConfirmNoticePage(pageVO, ExImTypeEnum.EX.getValue());
        return CommonResult.success(new PageResult<>(pageResult.getList(), pageResult.getTotal()));
    }
}
